package com.boot.core.protocol

import com.alibaba.fastjson.JSONArray
import com.alibaba.fastjson.JSONObject
import com.boot.core.result.ResultTo
import com.boot.mgt.controller.LoginController
import com.boot.mgt.controller.accident.StatisticsController
import com.boot.mgt.controller.app.*
import com.boot.mgt.controller.web.RoadRepairController
import com.boot.mgt.controller.web.TaAccidentReportController
import com.boot.mgt.controller.web.TaPoliceController
import com.boot.mgt.controller.web.vo.TaPoliceVo
import com.boot.mgt.dao.mysql.TaPoliceMapper
import com.boot.mgt.dao.mysql.TaSessionMapper
import com.boot.mgt.model.*
import com.boot.mgt.service.TaAccidentService
import com.boot.mgt.service.TaPoliceService
import com.fasterxml.jackson.databind.ObjectMapper
import com.google.gson.*
import org.apache.commons.io.IOUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
import java.io.IOException
import java.io.OutputStream
import java.lang.reflect.Field
import java.lang.reflect.Type
import java.text.SimpleDateFormat
import java.util.*
import java.util.regex.Pattern
import javax.servlet.ServletInputStream
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse


@ResponseBody
@RestController
@RequestMapping(value = ["/"])
@CrossOrigin
class AppConnectionController(
    private var taAppAccidentReportController: TaAppAccidentReportController,
    private var taAccidentReportController: TaAccidentReportController,
    private var taAppAccidentController: TaAppAccidentController,
    private var loginController: LoginController,
    private var taPoliceController: TaPoliceController,
    private var roadRepairController: RoadRepairController,
    private var taAppAccidentStatisticsController: TaAppAccidentStatisticsController,
    private var statisticsController: StatisticsController,
    private var taAppExceptionMsgController: TaAppExceptionMsgController,
    private var taLocationReportController: TaLocationReportController,
    private var taAccidentImageController: TaAccidentImageController,
    private var taHmsPushController: TaHmsPushController,
    private var noteRapporterController: NoteRapporterController,
    private var objectMapper: ObjectMapper
) {
    /*
     * 事故勘察助手 appid: 4b4127fc3b9a4035be3159c3caa7a85e
     * 数据源ID: 0837480a3474403391b6a735dd2de3bf
     * app访问地址: http://192.168.20.70:7070/drs/json-rpc
     */
    private val APP_ID: String? = "4b4127fc3b9a4035be3159c3caa7a85e"
    private val DATASOURCE_ID: String? = "0837480a3474403391b6a735dd2de3bf"
    private val APP_VISIT_URL: String? = "http://192.168.20.70:7070/drs/json-rpc"


    @Autowired
    lateinit var sessionMapper: TaSessionMapper

    @Autowired
    private lateinit var accidentService: TaAccidentService

    @Autowired
    private lateinit var policeService: TaPoliceService

    @Autowired
    protected lateinit var policeMapper: TaPoliceMapper

    /*fun connect(httpServletRequest: HttpServletRequest, httpServletResponse: HttpServletResponse) {
        val output: OutputStream = httpServletResponse.getOutputStream()
        val inputStream: ServletInputStream = httpServletRequest.getInputStream()
        var jsonParam: String? = null
        try {
            jsonParam = IOUtils.toString(inputStream, "UTF-8")
            log.debug("[connect] the request of json string is:$jsonParam")
        } catch (e: IOException) {
            log.error("[connect] the request of json string err: ", e)
        }

        //SysInfo sysInfo = (SysInfo)httpServletRequest.getSession().getServletContext().getAttribute("SysInfo");
        val remoteAddr = httpServletRequest.remoteAddr
        val remotePort = httpServletRequest.remotePort
        log.debug("remoteAddr=$remoteAddr")
        log.debug("remotePort=$remotePort")
        val context = HandlerContext()
        //context.setSysInfo(sysInfo);
        //context.setSysInfo(sysInfo);
        context.remoteAddr = remoteAddr
        context.remotePort = remotePort
        context.type = HandlerContext.Type.JSON_RPC
        context.isCheckSession = true //设置当前需要会话校验

        val handler = JsonRpcHandler()
        handler.handler(output, context, jsonParam)
    }*/


    @PostMapping(value = ["/"])
    fun getTendencyForApp(httpServletRequest: HttpServletRequest, httpServletResponse: HttpServletResponse): Any? {
        //TODO: 重构重点优化,应该屏蔽json-rpc格式包装细节,开发人员无感写代码 by rankai
        val inputStream: ServletInputStream = httpServletRequest.getInputStream()
        var jsonParam: String? = null
        try {
            jsonParam = IOUtils.toString(inputStream, "UTF-8")
            log.debug("the request of json string is:$jsonParam")
        } catch (e: IOException) {
            log.error("the request of json string err: ", e)
        }
        val remoteAddr = httpServletRequest.remoteAddr
        val remotePort = httpServletRequest.remotePort
        log.debug("remoteAddr=$remoteAddr")
        log.debug("remotePort=$remotePort")

        var jsonString: String? = jsonParam
        log.info("JSON-RPC 2.0 === connect String Information, jsonString ---------- \n{}", jsonString)
        var jsonStringChange: String? = jsonString?.split("\",\"stream")?.get(0)
        log.info("jsonStringChange === \n{}", jsonStringChange)
        val jsonStr: JSONObject? = JSONObject.parseObject(jsonStringChange)
        val methodType: String? = jsonStr?.get("method") as String
        var sign: String? = "awq12m678"
        when (methodType) {
            // 建立连接
            "connect" -> {
                log.info("JSON-RPC 2.0 === connect get Connections ---------- start")
                val connRequestOfApp: ConnRequestOfApp =
                    JSONObject.parseObject(jsonStringChange, ConnRequestOfApp::class.java)
                var dataRequest: ConnRequestOfApp.ConnParamsOfApp.Data? = connRequestOfApp.params?.data
                var connResponseForApp: ConnResponseForApp = ConnResponseForApp()
                var data: ConnResponseForApp.ConnectResultForApp.Data? = ConnResponseForApp.ConnectResultForApp.Data(
                    "f534ceba2920499d9511ddd1055e8196",
                    "4b4127fc3b9a4035be3159c3caa7a85e",
                    dataRequest?.timestamp,
                    dataRequest?.nonce
                )
//                var uuid = UUID.randomUUID().toString().replace("-", "")
//                var data: ConnResponseForApp.ConnectResultForApp.Data? = ConnResponseForApp.ConnectResultForApp.Data(uuid, "4b4127fc3b9a4035be3159c3caa7a85e", dataRequest?.timestamp, dataRequest?.nonce)
                var result: ConnResponseForApp.ConnectResultForApp =
                    ConnResponseForApp.ConnectResultForApp(data, 1, "OK", "sign")
                connResponseForApp.jsonrpc = connRequestOfApp.jsonrpc
                connResponseForApp.id = connRequestOfApp.id.toString()
                connResponseForApp.result = result
                log.info(
                    "JSON-RPC 2.0 === connect get Connections return result ---------- \n {}",
                    Gson().toJson(connResponseForApp)
                )
                log.info("JSON-RPC 2.0 === connect get Connections ---------- end")
                return Gson().toJson(connResponseForApp)
            }
            // 查询操作
            "query" -> {
                log.info("JSON-RPC 2.0 === query ---------- start")
                val queryRequestOfApp: QueryRequestOfApp =
                    JSONObject.parseObject(jsonStringChange, QueryRequestOfApp::class.java)
                val data: QueryRequestOfApp.QueryParamsOfApp.Data? = queryRequestOfApp.params?.data
                val userInfo: QueryRequestOfApp.QueryParamsOfApp.Data.UserInfo? =
                    queryRequestOfApp.params?.data?.userInfo
                var extAttrOriginal: HashMap<String, Any?>? = queryRequestOfApp.params?.data?.userInfo?.extAttr
                val dataObjId: String? = queryRequestOfApp.params?.data?.dataObjId
                val sourceId: String? = queryRequestOfApp.params?.data?.source?.sourceId
                val page: QueryRequestOfApp.QueryParamsOfApp.Data.Page? = queryRequestOfApp.params?.data?.page

                val interfaceMethod: String = extAttrOriginal?.get("interfaceMethod") as String
                val extAttr = hashMapOf<String, Any>()
                extAttrOriginal?.forEach { t, u -> if (t != "interfaceMethod" && u != null) extAttr[t] = u }

                log.info("JSON-RPC 2.0 === query JSONObject ---------- \n{}", Gson().toJson(queryRequestOfApp))

                /*
                if(APP_ID != data?.appId) {
                    var dataResponse: QueryResponseForApp.QueryResultForApp.Data = QueryResponseForApp.QueryResultForApp.Data(source, arrayListOf())
                    var page: QueryResponseForApp.QueryResultForApp.Page = QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
                    var result: QueryResponseForApp.QueryResultForApp = QueryResponseForApp.QueryResultForApp(dataResponse, page, "3", "无效会话", "sign")
                    return QueryResponseForApp().QueryResponseForApp(result)
                }
                */
                var queryResponseForApp: QueryResponseForApp = QueryResponseForApp()
                if ("accident" == dataObjId) {
                    if ("accidentReportList" == interfaceMethod) {//
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var map = hashMapOf<String, Any>()
                        extAttr?.forEach { t, u -> if (u != null) map[t] = u }

//                        var id: Int = (extAttr)?.get("pageindex") as Int
                        var resultTo: ResultTo =
                            taAppAccidentReportController.listRpc(map, page?.pageNo, page?.pageSize)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                Gson().toJson(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["report_list"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    if ("accidentReportDetail" == interfaceMethod) {// /app/report/detail
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var id: Int = (extAttr)?.get("id") as Int
                        var resultTo: ResultTo = taAppAccidentReportController.detail(id)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("data", objectMapper.writeValueAsString(resultTo), 0, "")
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((arrayListOf(resultTo)).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    if ("imageSelectById" == interfaceMethod) {// /app/image
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var id: Int = (extAttr)?.get("id") as Int
                        var resultTo: ResultTo = taAccidentImageController.select(id)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((arrayListOf(resultTo)).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    if ("selectForwardLog" == interfaceMethod) {// /admin/report/selectForwardLog
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var accident_report_id: Int = (extAttr)?.get("accident_report_id") as Int
                        var resultTo: ResultTo = taAccidentReportController.selectForwardLog(accident_report_id)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["forwardLog"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    if ("forwardPoliceList" == interfaceMethod) {// /app/accident/forward_list/
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var name: String? = (extAttr)?.get("name") as String
                        var police_number: String? = (extAttr)?.get("police_number") as String
                        var org_num: String? = (extAttr)?.get("org_num") as String
                        var resultTo: ResultTo =
                            taAppAccidentController.forwardPoliceListRpc(name, police_number, org_num)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["policeList"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    if ("getMqMsg" == interfaceMethod) {// /app/accident/getMqMsg
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var police_number: String = (extAttr)?.get("police_number") as String
                        var resultTo: ResultTo = taAppAccidentController.getMqMsg(police_number) as ResultTo

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["taHmsPushList"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    /*
                     * 警员定位管理
                     * @editor dongzz 2021-01-19
                     * @editcont APP暂无调用
                     */
                    if ("locationReportSelectByNum" == interfaceMethod) {// /app/location_report/
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var police_number: String = (extAttr)?.get("police_number") as String
                        var resultTo: ResultTo = taLocationReportController.selectByNum(police_number)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["data"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    /*
                     * 关联数据
                     * @editor dongzz 2021-01-19
                     * @editcont APP暂无调用
                     */
                    if ("accidentReportByReportId" == interfaceMethod) {// val APP_REPORT = ""       // 原/app/report/{reportId}
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var reportId: Int = (extAttr)?.get("reportId") as Int
                        var org_num: String? = (extAttr)?.get("org_num") as String
                        var resultTo: ResultTo = taAppAccidentReportController.correlationRpc(reportId, org_num)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    if ("accidentReportByReportIdAndOracleId" == interfaceMethod) {// val APP_REPORT_BIND = ""  // 原/app/report/{reportId}/{oracleId}
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var reportId: Int = (extAttr)?.get("reportId") as Int
                        var sgbh: String = (extAttr)?.get("sgbh") as String
                        var resultTo: ResultTo = taAppAccidentReportController.checkCorrelationRpc(reportId, sgbh)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    /*
                     * 根据登记编号获取oracle详细信息
                     * @editor dongzz 2021-01-19
                     * @editcont APP无调用处
                     */
                    if ("accidentReportByOracleId" == interfaceMethod) {// val APP_REPORT_BIND = ""  // 原/app/report/{reportId}/{oracleId}
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var sgbh: String = (extAttr)?.get("sgbh") as String
                        var resultTo: ResultTo = taAppAccidentReportController.selectOracleById(sgbh)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                }

                if ("police" == dataObjId) {//
                    if ("login" == interfaceMethod) {// /police/login
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)

                        val taSession = TaSession()
                        // log.info("JSON-RPC 2.0 === query ---------- police replace insert session_key \n {}", "f534ceba2920499d9511ddd1055e8196")
                        var police_number: String = (extAttr)?.get("police_number") as String
                        var password: String = (extAttr)?.get("password") as String
                        var login_type: Int? = (extAttr)?.get("login_type") as Int
                        var resultTo: ResultTo = loginController.login(police_number, password, login_type)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    if ("logout" == interfaceMethod) {// /police/logout
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var session_key: String = (extAttr)?.get("session_key") as String
                        var resultTo: ResultTo = loginController.logout(session_key)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    /*
                     * @editor dongzz 2021-01-19
                     * @editcont APP无调用处
                     */
                    if ("isLogin" == interfaceMethod) {// /police/isLogin
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var resultTo: ResultTo = loginController.logout()

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                }

                if ("road" == dataObjId) {
                    if ("roadManagerList" == interfaceMethod) {// /admin/roadManager/list
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var roadName: String? = (extAttr)?.get("roadName") as String
                        var createTime_begin: String? = (extAttr)?.get("createTime_begin") as String
                        var createTime_end: String? = (extAttr)?.get("createTime_end") as String
                        var resultTo: ResultTo = roadRepairController.listRpc(
                            hashMapOf<String, Any>(),
                            roadName,
                            createTime_begin,
                            createTime_end
                        )

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["road_list"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                }

                if ("map" == dataObjId) {
                    if ("accidentMapAll" == interfaceMethod) {// /app/statistics/accident_map_all
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var police_number: String = (extAttr)?.get("police_number") as String
                        var start_time: Date =
                            SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse((extAttr)?.get("start_time") as String)
                        var end_time: Date =
                            SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse((extAttr)?.get("end_time") as String)
                        var resultTo: ResultTo =
                            taAppAccidentStatisticsController.accidentMapAllRpc(start_time, end_time, police_number)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["data"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    /*
                     * @editor dongzz 2021-01-19
                     * @editcont APP无调用处, 后端无源码
                     */
                    if ("accidentMapType" == interfaceMethod) {// /app/statistics/type
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                    }
                    /*
                     * @editor dongzz 2021-01-19
                     * @editcont APP无调用处, 后端无源码
                     */
                    if ("accidentMapAllDealType" == interfaceMethod) {// /app/statistics/deal-type
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                    }
                    /*
                     * @editor dongzz 2021-01-19
                     * @editcont APP无调用处, 后端无源码
                     */
                    if ("accidentMapSection" == interfaceMethod) {// /app/statistics/section
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                    }
                    /*
                     * @editor dongzz 2021-01-19
                     * @editcont APP无调用处, 后端无源码
                     */
                    if ("accidentMapAllCaseHour" == interfaceMethod) {// /app/statistics/case-hour
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                    }
                    if ("accidentMapOld" == interfaceMethod) {// /app/statistics/accident_map_old
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var org_num: String? = (extAttr)?.get("org_num") as String
                        var start_time: Date =
                            SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse((extAttr)?.get("start_time") as String)
                        var end_time: Date =
                            SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse((extAttr)?.get("end_time") as String)
                        var resultTo: ResultTo =
                            taAppAccidentStatisticsController.accidentMapOldRpc(start_time, end_time, org_num)

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["data"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                    /*
                     * 一般事故
                     * @editor dongzz 2021-01-19
                     * @editcont
                     */
                    if ("apiAccident" == interfaceMethod) {// /api/statistics/accident/
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var start_time: Date =
                            SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse((extAttr)?.get("start_time") as String)
                        var end_time: Date =
                            SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse((extAttr)?.get("end_time") as String)
                        var deathStart: Int = (extAttr)?.get("deathStart") as Int
                        var deathEnd: Int = (extAttr)?.get("deathEnd") as Int
                        var police_level: Int = (extAttr)?.get("police_level") as Int
                        var resultTo: ResultTo = statisticsController.generalAccidentRpc(
                            start_time,
                            end_time,
                            deathStart,
                            deathEnd,
                            police_level
                        )

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                }

                if ("message" == dataObjId) {
                    /*
                     * 系统异常日志信息
                     * @editor dongzz 2021-01-19
                     * @editcont
                     */
                    if ("expMsgSelectAll" == interfaceMethod) {// /app/exp_msg/
                        log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                        var resultTo: ResultTo = taAppExceptionMsgController.selectAll()

                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(
                                page?.pageNo,
                                page?.pageSize,
                                ((resultTo["data"] as ArrayList<Any?>).size).toLong()
                            )
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }

                    if ("msgList" == interfaceMethod) {
                        var page_index: Int? = (extAttr)?.get("page_index") as Int
                        var page_size: Int? = (extAttr)?.get("page_size") as Int
                        var hmsType: Int? = (extAttr)?.get("hmsType") as Int
                        var police_number: String? = (extAttr)?.get("police_number") as String
                        var resultTo: ResultTo =
                            taHmsPushController.msgList(hmsType, police_number, page_index, page_size)
                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 0)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }

                    if ("selectUserAll" == interfaceMethod) {
                        var police_number: String? = (extAttr).get("police_number") as String
                        var resultTo: ResultTo = noteRapporterController.selectUserAll()
                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")
                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }

                    if ("selectNoteById" == interfaceMethod) {
                        var id: Int? = (extAttr)?.get("id") as Int
                        var resultTo: ResultTo = noteRapporterController.selectNoteById(id)
                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }

                }
                /*
                 * 统一认证票据验证接口
                 * 1.验证结果flag：0验证通过，1票据信息过期，2票据信息验证未通过，3该票据信息不属于平台发放票据，4其它错误。
                 * 待定 20201224
                 * result_20201225: 弃用
                 *      统一认证服务接口不需进行JSON-RPC数据服务包装
                 */
                if ("verifyBillUnify" == dataObjId) {// /
                    log.info("JSON-RPC 2.0 === query ---------- {}", interfaceMethod)
                    var strBill: String = (extAttr)?.get("strBill") as String
                    var resultVeriry = loginController.verifyBillUnify(strBill)
                    return resultVeriry
                }

                if ("accidentReport" == dataObjId) {
                    if ("correlation" == interfaceMethod) {
                        var reportId: Int? = (extAttr)?.get("reportId") as Int
                        var org_num: String? = (extAttr)?.get("org_num") as String
                        var resultTo: ResultTo = taAppAccidentReportController.correlationRpc(reportId!!, org_num)
                        var fieldValuesList: ArrayList<QueryResponseForApp.QueryResultForApp.Data.FieldValues>? =
                            arrayListOf()
                        var fieldValuesId: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues("id", "", 0, "")
                        var fieldValuesData: QueryResponseForApp.QueryResultForApp.Data.FieldValues =
                            QueryResponseForApp.QueryResultForApp.Data.FieldValues(
                                "data",
                                objectMapper.writeValueAsString(resultTo),
                                0,
                                ""
                            )
                        fieldValuesList?.add(fieldValuesId)
                        fieldValuesList?.add(fieldValuesData)
                        var dataResponse: QueryResponseForApp.QueryResultForApp.Data =
                            QueryResponseForApp.QueryResultForApp.Data(sourceId, fieldValuesList)
                        var page: QueryResponseForApp.QueryResultForApp.Page =
                            QueryResponseForApp.QueryResultForApp.Page(page?.pageNo, page?.pageSize, 1)
                        var result: QueryResponseForApp.QueryResultForApp =
                            QueryResponseForApp.QueryResultForApp(arrayListOf(dataResponse), page, 1, "OK", "sign")

                        queryResponseForApp.jsonrpc = queryRequestOfApp.jsonrpc
                        queryResponseForApp.id = queryRequestOfApp.id.toString()
                        queryResponseForApp.result = result
                    }
                }

                log.info(
                    "JSON-RPC 2.0 === query ---------- {} return result \n {}",
                    interfaceMethod,
                    objectMapper.writeValueAsString(queryResponseForApp)
                )
                return objectMapper.writeValueAsString(queryResponseForApp)
            }
            // 数据操作
            "operate" -> {
                log.info("JSON-RPC 2.0 === operate ---------- start")
                var operateResponseForApp: OperateResponseForApp = OperateResponseForApp()
                var operationListResponse: ArrayList<OperateResponseForApp.OperateResultForApp.Operation> =
                    arrayListOf()

                var operateRequestOfApp: OperateRequestOfApp =
                    JSONObject.parseObject(jsonStringChange, OperateRequestOfApp::class.java)
                var params: OperateRequestOfApp.OperateParamsOfApp? = operateRequestOfApp?.params
                var data: OperateRequestOfApp.OperateParamsOfApp.Data? = params?.data
                var userInfo: OperateRequestOfApp.OperateParamsOfApp.Data.UserInfo? = data?.userInfo
                var operations: ArrayList<OperateRequestOfApp.OperateParamsOfApp.Data.Operation>? = data?.operations

                var extAttrOriginal: HashMap<String, Any?>? = data?.userInfo?.extAttr
                val interfaceMethod = extAttrOriginal?.get("interfaceMethod") as String
                val org_num = extAttrOriginal?.get("org_num") as String
                val police_number = extAttrOriginal?.get("police_number") as String
                val extAttr = hashMapOf<String, Any>()
                extAttrOriginal?.forEach { t, u ->
                    if (t != "interfaceMethod" && t != "org_num" && t != "police_number" && u != null) extAttr[t] = u
                }

                log.info("JSON-RPC 2.0 === operate JSONObject ---------- \n{}", objectMapper.writeValueAsString(operateRequestOfApp))

                if (operations != null && operations.size > 0) {
                    operations?.forEach { it ->

                        var operationType: Int? = it.operationType
                        var operationId: String? = it.operationId
                        var sourceId: String? = it.sourceId
                        var dataObjId: String? = it.dataObjId
                        var condition: String? = it.condition
                        var dataListOfOperation: ArrayList<OperateRequestOfApp.OperateParamsOfApp.Data.Operation.Data>? =
                            it?.data

                        if ("accident" == dataObjId) {
                            if ("policeAccept" == interfaceMethod) {// /app/accident/police_accept
                                log.info("JSON-RPC 2.0 === operate ---------- policeAccept")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataJSONObject: JSONObject =
                                        JSONObject.parseObject(fieldValuesJSON["data"] as String)
                                    var has_accepted: Int = dataJSONObject["has_accepted"] as Int
                                    var accident_report_id: Int = dataJSONObject["accident_report_id"] as Int
                                    var resultTo: ResultTo = taAppAccidentController.policeAcceptRpc(
                                        has_accepted,
                                        accident_report_id,
                                        police_number
                                    )

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("policeAddReport" == interfaceMethod) {// /app/accident/police_add_report
                                log.info("JSON-RPC 2.0 === operate ---------- policeAddReport")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    val s = fieldValuesJSON["data"] as String?
                                    val p = Pattern.compile("_([a-zA-Z])")
                                    val m = p.matcher(s)
                                    val sb = StringBuffer()
                                    while (m.find()) {
                                        m.appendReplacement(sb, m.group(1).toUpperCase())
                                    }
                                    m.appendTail(sb)
                                    var dataStr: String? = sb.toString()
                                    val builder = GsonBuilder()
                                    builder.registerTypeAdapter(Date::class.java, object : JsonDeserializer<Date?> {
                                        @Throws(JsonParseException::class)
                                        override fun deserialize(
                                            json: JsonElement,
                                            typeOfT: Type?,
                                            context: JsonDeserializationContext?
                                        ): Date? {
                                            return Date(json.asJsonPrimitive.asLong)
                                        }
                                    })
                                    val gson = builder.create()
                                    var taAccident: TaAccident = gson.fromJson(dataStr, TaAccident::class.java)
                                    var resultTo: ResultTo =
                                        taAppAccidentController.policeAddReportRpc(taAccident, police_number)
                                    var taAccidentId: Int? = resultTo?.get("taAccidentId") as Int

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])
                                    operationMessageMap?.put("taAccidentId", taAccidentId)

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("policeAddReportImage" == interfaceMethod) {// /app/accident/upload_image
                                log.info("JSON-RPC 2.0 === operate ---------- policeAddReportImage")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    val s = fieldValuesJSON["data"] as String?
                                    val p = Pattern.compile("_([a-zA-Z])")
                                    val m = p.matcher(s)
                                    val sb = StringBuffer()
                                    while (m.find()) {
                                        m.appendReplacement(sb, m.group(1).toUpperCase())
                                    }
                                    m.appendTail(sb)
                                    var dataStr: String? = sb.toString()
                                    val builder = GsonBuilder()
                                    builder.registerTypeAdapter(Date::class.java, object : JsonDeserializer<Date?> {
                                        @Throws(JsonParseException::class)
                                        override fun deserialize(
                                            json: JsonElement,
                                            typeOfT: Type?,
                                            context: JsonDeserializationContext?
                                        ): Date? {
                                            return Date(json.asJsonPrimitive.asLong)
                                        }
                                    })
                                    val gson = builder.create()
                                    var taAccidentImage: TaAccidentImage =
                                        Gson().fromJson(dataStr, TaAccidentImage::class.java)
                                    var resultTo: ResultTo =
                                        taAppAccidentController.policeAddReportImage(taAccidentImage)

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("locationReportInsert" == interfaceMethod) {// /app/location_report/
                                log.info("JSON-RPC 2.0 === operate ---------- locationReportInsert")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataStr: String? = fieldValuesJSON["data"] as String?
                                    var taLocationReport: TaLocationReport =
                                        Gson().fromJson(dataStr, TaLocationReport::class.java)
                                    var resultTo: ResultTo =
                                        taLocationReportController.insertRpc(taLocationReport, police_number)

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("policeForward" == interfaceMethod) {// /app/accident/forward_report/
                                log.info("JSON-RPC 2.0 === operate ---------- policeForward")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataJSONObject: JSONObject =
                                        JSONObject.parseObject(fieldValuesJSON["data"] as String)
                                    var police_number_target: String = dataJSONObject["police_number"] as String
                                    var accident_report_id: Int = dataJSONObject["accident_report_id"] as Int
                                    var resultTo: ResultTo = taAppAccidentController.policeForward(
                                        police_number,
                                        police_number_target,
                                        accident_report_id
                                    )

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                        }

                        if ("police" == dataObjId) {
                            if ("policeEdit" == interfaceMethod) {// /admin/police/edit
                                val police_level = extAttrOriginal?.get("police_level") as Int
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataJSONObject: JSONObject =
                                        JSONObject.parseObject(fieldValuesJSON["data"] as String)
                                    var police_id: String = dataJSONObject["police_id"] as String
                                    var old_pwd: String = dataJSONObject["old_pwd"] as String
                                    var password: String = dataJSONObject["password"] as String

                                    val taPoliceVo = TaPoliceVo()
                                    taPoliceVo.password = password
                                    taPoliceVo.oldPwd = old_pwd
                                    var resultTo: ResultTo =
                                        taPoliceController.editRpc(taPoliceVo, police_level, police_id, org_num)
                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }

                            }
                        }

                        if ("road" == dataObjId) {
                            if ("roadManagerUploadOneImg" == interfaceMethod) {// /admin/roadManager/uploadOneImg
                                log.info("JSON-RPC 2.0 === operate ---------- roadManagerUploadOneImg")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    var fieldValuesMapCovert: HashMap<String, String> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataJSONObject: JSONObject =
                                        JSONObject.parseObject(fieldValuesJSON["data"] as String)
                                    var police_number: String = dataJSONObject["police_number"] as String
                                    var accident_report_id: Int = dataJSONObject["accident_report_id"] as Int
                                    var img: String = dataJSONObject["img"] as String

                                    var resultTo: ResultTo =
                                        roadRepairController.uploadOneImgRpc(police_number, accident_report_id, img)

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("roadManagerAdd" == interfaceMethod) {// /admin/roadManager/add
                                log.info("JSON-RPC 2.0 === operate ---------- roadManagerAdd")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataStr: String? = fieldValuesJSON["data"] as String?
                                    var taRoadRepair: TaRoadRepair = Gson().fromJson(dataStr, TaRoadRepair::class.java)
                                    var resultTo: ResultTo = roadRepairController.add(taRoadRepair)

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("roadManagerEdit" == interfaceMethod) {// /admin/roadManager/edit
                                log.info("JSON-RPC 2.0 === operate ---------- roadManagerEdit")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataStr: String? = fieldValuesJSON["data"] as String?
                                    var taRoadRepair: TaRoadRepair = Gson().fromJson(dataStr, TaRoadRepair::class.java)
                                    var resultTo: ResultTo = roadRepairController.edit(taRoadRepair)

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                        }

                        if ("message" == dataObjId) {
                            if ("expMsgSelectInsert" == interfaceMethod) {// /app/exp_msg/
                                log.info("JSON-RPC 2.0 === operate ---------- expMsgSelectInsert")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject

                                    var dataStr: String? = fieldValuesJSON["data"] as String?
                                    var taAppExceptionMsg: TaAppExceptionMsg =
                                        Gson().fromJson(dataStr, TaAppExceptionMsg::class.java)
                                    var resultTo: ResultTo = taAppExceptionMsgController.insert(taAppExceptionMsg)

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("imageInsert" == interfaceMethod) {// /app/image/
                                log.info("JSON-RPC 2.0 === operate ---------- imageInsert")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataStr: String? = fieldValuesJSON["data"] as String?
                                    var taAccidentImage: TaAccidentImage =
                                        Gson().fromJson(dataStr, TaAccidentImage::class.java)
                                    var resultTo: ResultTo = taAccidentImageController.delete(taAccidentImage)

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("imageDeleteById" == interfaceMethod) {// /app/image/
                                log.info("JSON-RPC 2.0 === operate ---------- imageDeleteById")
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataJSONObject: JSONObject =
                                        JSONObject.parseObject(fieldValuesJSON["data"] as String)
                                    var id: Int = dataJSONObject["id"] as Int
                                    var resultTo: ResultTo = taAccidentImageController.delete(id)

                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                            if ("sendSuccess" == interfaceMethod) {
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataJSONObject: JSONObject =
                                        JSONObject.parseObject(fieldValuesJSON["data"] as String)
                                    var msgId: Int = dataJSONObject["msgId"] as Int
                                    var resultTo: ResultTo = taHmsPushController.sendSuccess(msgId)
                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                        }

                        if ("insertTaNote" == interfaceMethod) {
                            dataListOfOperation?.forEach { d ->
                                var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                fieldValues?.forEach { f ->
                                    fieldValuesMap.put(f["field"] as String, f["value"])
                                }
                                var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                val s = fieldValuesJSON["data"] as String?
                                val p = Pattern.compile("_([a-zA-Z])")
                                val m = p.matcher(s)
                                val sb = StringBuffer()
                                while (m.find()) {
                                    m.appendReplacement(sb, m.group(1).toUpperCase())
                                }
                                m.appendTail(sb)
                                var dataStr: String? = sb.toString()
                                val builder = GsonBuilder()
                                val gson = builder.create()
                                var taNote: TaNote = gson.fromJson(dataStr, TaNote::class.java)
                                var resultTo: ResultTo = noteRapporterController.insertTaNote(taNote)
                                var taNoteId: Int? = resultTo?.get("taNoteId") as Int

                                var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                operationMessageMap?.put("message", resultTo["err_message"])
                                operationMessageMap?.put("taNoteId", taNoteId)

                                var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                    OperateResponseForApp.OperateResultForApp.Operation(
                                        operationId as String,
                                        if (0 == resultTo["err_code"] as Int) "1" else "2",
                                        objectMapper.writeValueAsString(operationMessageMap),
                                        1
                                    )
                                operationListResponse.add(operationResponse)
                            }

                        }

                        if ("accidentReport" == dataObjId) {
                            if ("checkCorrelation" == interfaceMethod) {
                                dataListOfOperation?.forEach { d ->
                                    var fieldValues: ArrayList<HashMap<String, Any?>>? = d?.fieldValues
                                    var fieldValuesMap: HashMap<String, Any?> = hashMapOf()
                                    fieldValues?.forEach { f ->
                                        fieldValuesMap.put(f["field"] as String, f["value"])
                                    }
                                    var fieldValuesJSON: JSONObject = JSONObject.toJSON(fieldValuesMap) as JSONObject
                                    var dataJSONObject: JSONObject =
                                        JSONObject.parseObject(fieldValuesJSON["data"] as String)
                                    var reportId: Int = dataJSONObject["reportId"] as Int
                                    var djbh: String = dataJSONObject["djbh"] as String
                                    var resultTo: ResultTo =
                                        taAppAccidentReportController.checkCorrelationRpc(reportId, djbh)
                                    var operationMessageMap: HashMap<String, Any?>? = hashMapOf()
                                    operationMessageMap?.put("message", resultTo["err_message"])

                                    var operationResponse: OperateResponseForApp.OperateResultForApp.Operation =
                                        OperateResponseForApp.OperateResultForApp.Operation(
                                            operationId as String,
                                            if (0 == resultTo["err_code"] as Int) "1" else "2",
                                            objectMapper.writeValueAsString(operationMessageMap),
                                            1
                                        )
                                    operationListResponse.add(operationResponse)
                                }
                            }
                        }

                    }
                }
                log.info(
                    "JSON-RPC 2.0 === operate ----------{} operate return result \n{}",
                    interfaceMethod,
                    objectMapper.writeValueAsString(OperateResponseForApp().OperateResponseForApp(operationListResponse, 1, "OK"))
                )
                return objectMapper.writeValueAsString(OperateResponseForApp().OperateResponseForApp(operationListResponse, 1, "OK"))
            }
        }
        return null
    }

    fun <T> covertData(data: JSONArray?, clazz: Class<T>): List<T>? {
        val map = hashMapOf<String, Any>()
        var resultList = arrayListOf<T>()
        data?.forEach {
            var obj: T = clazz.newInstance()
            (it as JSONObject).getJSONArray("fieldValues").forEach { v ->
                var dataCovert = (v as JSONObject).innerMap
                var name: String = dataCovert["field"] as String
                var value: String = dataCovert["value"] as String
                clazz.declaredFields.forEach { c ->
                    if (c.name == name) {
                        var field: Field = clazz.getDeclaredField(c.name);
                        field.isAccessible = true
                        field.set(obj, value)
                    }
                }
            }
            resultList.add(obj)
        }
        return resultList
    }

    companion object {
        private val log: Logger = LoggerFactory.getLogger(this::class.java)
    }

}